from django.conf import settings

from rest_framework import serializers


class GenerateAIFieldValueViewSerializer(serializers.Serializer):
    row_ids = serializers.ListField(
        child=serializers.IntegerField(),
        max_length=settings.BATCH_ROWS_SIZE_LIMIT,
        help_text="The ids of the rows that the values should be generated for.",
    )

    def to_internal_value(self, data):
        return super().to_internal_value(data)


class GenerateFormulaWithAIRequestSerializer(serializers.Serializer):
    ai_type = serializers.CharField(
        help_text="The AI model type that must be used when generating the formula."
    )
    ai_model = serializers.CharField(
        help_text="The AI model that must be used when generating the formula."
    )
    ai_temperature = serializers.FloatField(
        required=False,
        allow_null=True,
        min_value=0,
        max_value=2,
        help_text="Between 0 and 2, adjusts response randomness—lower values yield "
        "focused answers, while higher values increase creativity.",
    )
    ai_prompt = serializers.CharField(
        help_text="The human readable input used to generate the formula.",
        max_length=1000,
    )


class GenerateFormulaWithAIResponseSerializer(serializers.Serializer):
    formula = serializers.CharField(help_text="The formula generated by the AI.")
